package com.betterjr.modules.accountSupervision.dubbo;

import com.alibaba.dubbo.config.annotation.Service;
import com.betterjr.common.web.AjaxObject;
import com.betterjr.mapper.pagehelper.Page;
import com.betterjr.modules.accountSupervision.IScfRepaymentService;
import com.betterjr.modules.accountSupervision.service.ScfAccountDetailService;
import com.betterjr.modules.accountSupervision.service.ScfExceptionService;
import com.betterjr.modules.accountSupervision.service.ScfRepaymentService;
import com.betterjr.modules.accountSupervision.service.ScfWarnService;
import org.springframework.beans.factory.annotation.Autowired;

import java.text.ParseException;
import java.util.List;
import java.util.Map;

@Service(interfaceClass = IScfRepaymentService.class)
public class ScfRepaymentDubboService implements IScfRepaymentService {

    @Autowired
    private ScfRepaymentService scfRepaymentService;

    @Autowired
    private ScfWarnService scfWarnService;
    @Autowired
    private ScfExceptionService scfExceptionService;
    @Autowired
    private ScfAccountDetailService scfAccountDetailService;

    @Override
    public String webQueryAllRepayment(Map<String, Object> anMap, int flag, int anPageNum, int anPageSize) {
        return AjaxObject.newOkWithPage("还款监控查询成功", scfRepaymentService.queryAllRepayment(anMap,
                flag, anPageNum, anPageSize)).toJson();
    }

    @Override
    public String webQueryBalanceWarnList(Map<String, Object> anMap, int anPageNum, int anPageSize){
        try {
            return AjaxObject.newOkWithPage("异常事件(余额预警)查询成功", scfWarnService.queryBalanceWarnList(anMap,anPageNum, anPageSize)).toJson();
        } catch (ParseException e) {
            e.printStackTrace();
            return AjaxObject.newOkWithPage("异常事件(余额预警)查询失败",new Page()).toJson();
        }
    }

    @Override
    public String webQueryCapitalWarnList(Map<String, Object> anMap, int anPageNum, int anPageSize) {
        return AjaxObject.newOkWithPage("异常事件(本金预警)查询成功", scfWarnService.queryCapitalWarnList(anMap,anPageNum, anPageSize)).toJson();
    }

    @Override
    public String webQueryExceptionList(Map<String, Object> anMap, int anPageNum, int anPageSize) {
        return AjaxObject.newOkWithPage("异常事件(异常交易)查询成功", scfExceptionService.queryExceptionWarnList(anMap,anPageNum, anPageSize)).toJson();
    }

    @Override
    public String webQueryAccounBalanceList(Map<String, Object> anMap, int anPageNum, int anPageSize) {
        return AjaxObject.newOkWithPage("账户查询(余额查询)成功", scfAccountDetailService.queryAccounBalanceList(anMap,anPageNum, anPageSize)).toJson();
    }

    @Override
    public String webQueryAccounCountList(Map<String, Object> anMap, int anPageNum, int anPageSize) {
        return AjaxObject.newOkWithPage("账户查询(统计查询)成功", scfAccountDetailService.queryAccounCountList(anMap,anPageNum, anPageSize)).toJson();
    }

    @Override
    public String webQueryAccounStreamList(Map<String, Object> anMap, int anPageNum, int anPageSize) {
        return AjaxObject.newOkWithPage("账户查询(流水查询)成功", scfAccountDetailService.queryAccounStreamList(anMap,anPageNum, anPageSize)).toJson();
    }

//    @Override
//    public String test() {
//        scfWarnService.aotoBal();
//        return "测试余额定时扫描";
//    }
//
//    @Override
//    public String test1() {
//        scfWarnService.aotoDtl();
//        return "测试明细定时扫描";
//    }

    @Override
    public int queryCountRepayment(int flag,Map<String, Object> anMap) {
        return scfRepaymentService.queryCountRepayment(flag,anMap);
    }

    @Override
    public int queryBalanceWarnCount(Map<String, Object> anMap) {
        return scfWarnService.queryBalanceWarnCount(anMap);
    }

    @Override
    public int queryCapitalWarnCount(Map<String, Object> anMap) {
        return scfWarnService.queryCapitalWarnCount(anMap);
    }

    @Override
    public int queryExceptionWarnCount(Map<String, Object> anMap) {
        return scfExceptionService.queryExceptionWarnCount(anMap);
    }

    @Override
    public List<Map<String, Object>> getWarnCountByProviderId(String providerId) {
        return scfWarnService.getWarnCountByProviderId(providerId);
    }

}
